package com.fbd.servicepassengeruser.controller;

import com.fbd.internalcommon.dto.ResponseResult;
import com.fbd.internalcommon.dto.VerificationCodeDTO;
import com.fbd.servicepassengeruser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO){

        return userService.loginOrRegister(verificationCodeDTO.getPassengerPhone());
    }

    @GetMapping("/user/{phone}")
    public ResponseResult getUser(@PathVariable String phone){
        return  userService.getUserByPhone(phone);
    }
}
